package com.lovo.roomProject.system.dao.impl;

import com.lovo.roomProject.dao.BaseDAO;
import com.lovo.roomProject.pojo.AdminDO;
import com.lovo.roomProject.system.dao.SystemDAO;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class SystemDAOImpl extends BaseDAO implements SystemDAO {
    @Override
    public List listSystem() {
        this.getConnection();
        String sql = "select * from t_admin";
        List list = new ArrayList();
        try {
            preparedStatement = con.prepareStatement(sql);
            rs = preparedStatement.executeQuery();
            while (rs.next()) {
                AdminDO admin = new AdminDO();
                admin.setLevel(rs.getString("a_level"));
                admin.setName(rs.getString("a_name"));
                admin.setRealName(rs.getString("a_real_name"));
                admin.setPwd(rs.getString("a_pwd"));
                list.add(admin);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            close(con,preparedStatement,rs);
        }
        return list;
    }
}
